<?php
/**
 * TomatoCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version 	$Id: list.phtml 4135 2010-07-30 07:40:49Z huuphuoc $
 * @since		2.0.7
 */
?>
<?php
$this->headTitle($this->translator('gwebmaster_list_page_title'));
?>

<div class="grid_12 t_a_ui_breadcrumb">
	<span><?php echo $this->translator('breadcump'); ?></span>
	<span><?php echo $this->translator('gwebmaster_list_breadcrumb'); ?></span>
</div>

<div class="grid_12"><?php echo $this->flashMessenger(); ?></div>

<div class="grid_12 t_a_bottom">
	<!-- List sites -->
	<div class="grid_8 alpha">
	<?php if (0 == count($this->sites)) : ?>
		<?php echo $this->translator('gwebmaster_list_not_found'); ?>
	<?php else : ?>
		<div class="t_a_bottom"><?php echo $this->translator('gwebmaster_list_guide'); ?></div>
		
		<div class="t_a_ui_data_list_header">
			<div class="grid_6 alpha">
				<div><?php echo $this->translator('gwebmaster_list_site'); ?></div>
			</div>
			
			<div class="grid_2 omega"><?php echo $this->translator('gwebmaster_list_verified'); ?></div>
			
			<div class="clear"></div>
		</div>
		
		<?php foreach ($this->sites as $site) : ?>
		<div class="clearfix t_a_ui_data_list_content">
			<div class="grid_6 alpha">
				<div>
					<a href="<?php echo $site['link']; ?>"><?php echo $site['link']; ?></a>
				</div>
				<div class="t_a_ui_helper_action">
					<a href="<?php echo $this->url(array('url' => urlencode($site['link']), 'verified' => ('true' == $site['verified']) ? 'yes' : 'no'), 'seo_gwebmaster_details'); ?>"><?php echo $this->translator('gwebmaster_list_details_action'); ?></a>
				
					<?php if ($this->allow('delete')) : ?>
					| <a href="javascript: void(0);" title="<?php echo urlencode($site['link']); ?>" class="deleteAction""><?php echo $this->translator('gwebmaster_list_delete_site_action'); ?></a>
					<?php endif; ?>
				</div>
			</div>
			
			<div class="grid_2 omega"><?php echo (('true' == $site['verified']) ? $this->translator('gwebmaster_list_verified_yes') : $this->translator('gwebmaster_list_verified_no')); ?></div>
		</div>
		<?php endforeach; ?>
	<?php endif; ?>
	</div>
	
	<!-- Add new site -->
	<div class="grid_4 omega">
	<?php if ($this->allow('add')) : ?>
		<div class="t_a_ui_helper_line">
			<h3><?php echo $this->translator('gwebmaster_list_add_site'); ?></h3>
		</div>
		
		<div class="t_a_top">
			<div class="t_a_bottom"><?php echo $this->translator('gwebmaster_list_add_site_guide'); ?></div>
			<form method="post" action="<?php echo $this->url(array(), 'seo_gwebmaster_add'); ?>">
				<input type="text" style="width: 200px" name="url" />&nbsp;<button type="submit"><span><?php echo $this->translator('gwebmaster_list_add_site_button'); ?></span></button>
			</form>
		</div>
	<?php endif; ?>
	</div>
</div>

<script type="text/javascript">
$(document).ready(function() {
	<?php if ($this->allow('delete')) : ?>
	$('a.deleteAction').click(function() {
		var self = $(this);
		$(this).html('').addClass('t_a_ui_helper_loading');
		
		var url = $(this).attr('title');
		$.ajaxq('delete_site', {
			url: '<?php echo $this->url(array(), 'seo_gwebmaster_delete'); ?>',
			type: 'POST',
			data: { url: url },
			success: function(response) {
				if (response == 'RESULT_OK') {
					self.parents('.t_a_ui_data_list_content').remove();
				}
			}
		});
	});
	<?php endif; ?>
});
</script>
